<template>
  <div class="login-container">
    <el-card header="管理员注册" class="login-card">
      <el-form @submit.native.prevent="register">
        <el-form-item label="用户名">
          <el-input v-model="model.username" placeholder="admin"> </el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="model.password" placeholder="admin"> </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" native-type="submit">注册</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<style scoped>
.login-card {
  width: 30rem;
  margin: 0 auto;
  margin-top: 8rem;
}
</style>

<script>
export default {
  data() {
    return {
      model: {},
    };
  },
  methods: {
    async register() {
      await this.$http.post("register", this.model).then((data) => {
        this.$message({
          message: "用户注册成功",
          type: "success",
        });
        this.$router.push("/login");
        console.log(data);
      });
    },
  },
};
</script>
